package org.weasel.unittests;

import java.sql.Time;

import junit.framework.TestCase;

import org.weasel.business.Developer;
import org.weasel.business.Task;
import org.weasel.business.UserStory;
import org.weasel.business.Utilities;

public class UserStoryTest extends TestCase {
	private UserStory userStory;
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		userStory = new UserStory(Utilities.createUniqueId(), "user story 1", 3, Time.valueOf("12:00:00"), Time.valueOf("13:00:00"), 20, null, null);
	}

	@Override
	protected void tearDown() throws Exception {
		super.tearDown();
		userStory = null;
	}

	public void testDevelopers() {
		String id = Utilities.createUniqueId();
		Developer d = new Developer(id, "Matthias", "hallo@hotmail.com", "Manager");
		userStory.addDeveloper(d);
		assertEquals(id, userStory.getDeveloper(id).getId());
		assertEquals("Matthias", d.getName());
	}

	public void testRemoveDeveloper() {
		String id = Utilities.createUniqueId();
		Developer d = new Developer(id, "Matthias", "hallo@hotmail.com", "Manager");
		userStory.addDeveloper(d);
		
		userStory.removeDeveloper(id);
		
		assertEquals(null, userStory.getDeveloper(id));
	}

	public void testTasks() {
		String taskid = Utilities.createUniqueId();
		Task t = new Task(taskid,"this is the task desc", false);
		
		userStory.addTask(t);
		
		assertEquals(taskid, userStory.getTask(taskid).getId());
	}

	public void testRemoveTask() {
		String taskid = Utilities.createUniqueId();
		Task t = new Task(taskid,"this is the task desc",false);
		
		userStory.addTask(t);
		
		userStory.removeTask(taskid);
		assertEquals(null, userStory.getTask(taskid));
	}
}
